package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Mobile   string `gorm:"type:varchar(30)"`
	Password string `gorm:"type:char(32)"`
	RealName string `gorm:"type:varchar(30)"`
	IdCard   string `gorm:"type:char(18)"`
}
type Good struct {
	gorm.Model
	Title  string  `gorm:"type:varchar(40)"`
	Price  float64 `gorm:"type:decimal(10,2)"`
	Stock  int     `gorm:"type:int(11)"`
	Info   string  `gorm:"type:varchar(100)"`
	UserId int     `gorm:"type:int(11)"`
}

func (u *User) FindUserById(id int64) (*User, error) {
	err := DB.Debug().Where("id=?", id).Find(u).Error
	return u, err
}

func (u *User) AuthAdd() error {
	return DB.Debug().Create(u).Error
}
